package com.caigou.modules.famous.adpter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter

/**
 * @author #Suyghur.
 * Created on 2021/12/08
 */
class FamousPageAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) {

    private val fragments = mutableListOf<Fragment>()

    override fun getItemCount(): Int {
        return fragments.size
    }

    override fun createFragment(position: Int): Fragment {
        return fragments[position]
    }

    fun setList(list: MutableList<Fragment>) {
        fragments.clear()
        list.forEach {
            fragments.add(it)
        }
        notifyDataSetChanged()
    }
}